package com.unicom.mec.user.controller;


import com.unicom.mec.user.common.ResultBean;
import com.unicom.mec.user.service.UserService;
import com.unicom.mec.user.vo.UserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户前端控制器
 *
 * @author ZhuHao
 * @since 2020-07-07
 */
@Api(value = "UserController", tags = "用户管理")
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @ApiOperation(value = "注册用户")
    @PostMapping("/register")
    ResultBean<String> register(UserVo userVo){
        String resultInfo = userService.register(userVo);
        ResultBean<String> result = new ResultBean<>();
        if (StringUtils.equals(resultInfo, ResultBean.SUCCESS)) {
            result.setReturnMsg("用户注册成功");
        }else {
            result.setReturnCode(ResultBean.FAIL);
            result.setReturnMsg("用户注册失败");
        }
        return result;
    }
}

